//Date 2021.1.9

#include <stdio.h> 
#include <stdlib.h>

int main(void)
{
    int a1, a2, a3,
    a4, a5, a6, a7,
    a8, a9, a10, a11, a12;
    int sum1, sum2, total;
    printf ("Enter the first 11 digits of a EAN: ");
    scanf ("%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d", 
    &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10, &a11, &a12);
    sum1 = a2 + a4 + a6 + a8 + a10 + a12;
    sum2 = a1 + a3 + a5 + a7 + a9 + a11;
    total = 3 * sum1 + sum2 - 1;
    total = total % 10;
    printf ("Check digit: %d\n", 9 - total); 
    system ("pause");
    return 0;
}